import request from "@/utils/request";

export function getResources(paramters) {
  let url = "/api/identity/openIddict/scopes";
  return request({
    url: url,
    method: "get",
    params: paramters,
  });
}

export function getResource(name) {
  let url = "/api/identity/openIddict/scopes/" + name;
  return request({
    url: url,
    method: "get",
  });
}

export function addResource(data) {
  let url = "/api/identity/openIddict/scopes/";
  return request({
    url: url,
    method: "post",
    data: data,
  });
}

export function updateResource(data) {
  let url = "/api/identity/openIddict/scopes/";
  return request({
    url: url,
    method: "put",
    data: data,
  });
}

export function deleteResource(name) {
  let url = "/api/identity/openIddict/scopes/" + name;
  return request({
    url: url,
    method: "delete",
  });
}

export function getClients(paramters) {
  let url = "/api/identity/openIddict/clients";
  return request({
    url: url,
    method: "get",
    params: paramters,
  });
}

export function getClient(name) {
  let url = "/api/identity/openIddict/clients/" + name;
  return request({
    url: url,
    method: "get",
  });
}

export function addClient(data) {
  let url = "/api/identity/openIddict/clients/";
  return request({
    url: url,
    method: "post",
    data: data,
  });
}

export function updateClient(data) {
  let url = "/api/identity/openIddict/clients/";
  return request({
    url: url,
    method: "put",
    data: data,
  });
}

export function deleteClient(name) {
  let url = "/api/identity/openIddict/clients/" + name;
  return request({
    url: url,
    method: "delete",
  });
}

export function getClientType(clientId) {
  let url = `/api/identity/openIddict/clients/${clientId}/type`;
  return request({
    url: url,
    method: "get",
  });
}

export function addClientType(data) {
  let url = "/api/identity/openIddict/clients/type/";
  return request({
    url: url,
    method: "post",
    data: data,
  });
}

export function updateClientType(data) {
  let url = "/api/identity/openIddict/clients/type/" + data.id;
  return request({
    url: url,
    method: "put",
    data: data,
  });
}

export function getDefaultPermissions() {
  let url = `/api/identity/openIddict/clients/default-permission`;
  return request({
    url: url,
    method: "get",
  });
}
